using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using THSERP.BusinessEntities;
using THSERP.BaseProvider;
namespace THSERP.Modules.Handover
{
    public class BRPOSsGridControl : THSGridControl 
    {
        private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
    
        public override void InitGridControlDataSource()
        {
            //base.InitGridControlDataSource();
            HandoverEntities entity = (HandoverEntities)((BaseModuleERP)Screen.Module).CurrentModuleEntity;
            BindingSource bds = new BindingSource();
            bds.DataSource = entity.BRPOSPreparedList;
            this.DataSource = bds;
        }

        protected override DevExpress.XtraGrid.Views.Grid.GridView InitializeGridView()
        {
            //Check edit item privilege for gridview_Hieu.nguyen_29/04/2010
            DevExpress.XtraGrid.Views.Grid.GridView gridView = base.InitializeGridView();
            DevExpress.XtraGrid.Columns.GridColumn colTotalCost = gridView.Columns["BRPOSTotalAmount"];
            colTotalCost.SummaryItem.FieldName = "BRPOSTotalAmount";
            colTotalCost.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colTotalCost.SummaryItem.DisplayFormat = "{0:n2}";
            gridView.OptionsView.ShowFooter=true;
            return gridView;
        }

        protected override void GridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            base.GridView_CellValueChanged(sender, e);

            //POSEntities entity = (POSEntities)(this.Screen.Module as BaseModuleERP).CurrentModuleEntity;
            //if (entity.BRPOSItemsList.CurrentIndex >= 0)
            //{
            //    entity.ModuleObjects[POSEntities.strBRPOSItemsObjectName] = entity.BRPOSItemsList[entity.BRPOSItemsList.CurrentIndex].SetToBusinessObject(POSEntities.strBRPOSItemsObjectName);
            //    (entity.Module as POSModule).ChangeItemFromPOSItemsList();
            //}
        }

        protected override string GetLookupTableDisplayColumn(string strLookupTableName)
        {
            switch (strLookupTableName)
            {
                case "ICProducts":
                    return "ICProductName";
                case"GELocations":
                    return "GELocationName";
                default:
                    return base.GetLookupTableDisplayColumn(strLookupTableName);
            }
        }
    }
}
